﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CuaHangLaptop.DAL;

namespace CuaHangLaptop.BIZ
{
    public class CTHoaDon_BIZ
    {
        int id;
        string maCThoadon;
        HoaDon_BIZ hoadon = new HoaDon_BIZ();
        Laptop_BIZ laptop = new Laptop_BIZ();
        int soluong;

        public int ID
        {
            get { return id; }
            set { id = value; }
        }

        public string MaCThoadon
        {
            get { return maCThoadon; }
            set { maCThoadon = value; }
        }

        public HoaDon_BIZ Hoadon
        {
            get { return hoadon; }
            set { hoadon = value; }
        }

        public string TenLaptop
        {
            get { return laptop.TenLaptop; }
        }

        public Laptop_BIZ Laptop
        {
            get { return laptop; }
            set { laptop = value; }
        }

        public int Soluong
        {
            get { return soluong; }
            set { soluong = value; }
        }

        public CTHoaDon_BIZ()
        {
        }

        public CTHoaDon_BIZ(int _id, string _ma, string _hoadon, string _laptop, int _soluong)
        {
            id = _id;
            maCThoadon = _ma;
            hoadon = hoadon.Get_HoaDon_ByCode(_hoadon);
            laptop = laptop.Get_Laptop_ByCode(_laptop);
            soluong = _soluong;
        }

        public CTHoaDon_BIZ Get_CTHoaDon_ByCode(string _MaCTHD)
        {
            return CTHoaDon_DAL.Get_CTHoaDon_ByCode(_MaCTHD);
        }

        public List<CTHoaDon_BIZ> GetAll_CTHoaDon()
        {
            return CTHoaDon_DAL.GetAll_CTHD();
        }

        public void Save()
        {
            if (id == -1) id = CTHoaDon_DAL.Insert(this);
            else CTHoaDon_DAL.Update(this);
        }

        public void Delete()
        {
            CTHoaDon_DAL.Delete(this);
        }

        public int Get_Lasted_ID()
        {
            return CTHoaDon_DAL.Get_Lasted_ID();
        }
    }
}
